﻿namespace nPress.Core.Controller
{
    public abstract class ThemeControllerBase : System.Web.Mvc.Controller
    {
        protected override void Execute(System.Web.Routing.RequestContext requestContext)
        {
            // Add code here to set the Theme based on your database or some other storage
            requestContext.HttpContext.Items["themeName"] = "Default";

            
            // Allow the Theme to be overriden via the querystring
            // If a Theme Name is Passed in the querystring then use it and override the previously set Theme Name
            // http://localhost/Default.aspx?theme=Red
            var previewTheme = requestContext.HttpContext.Request.QueryString["template"];
            if (!string.IsNullOrEmpty(previewTheme))
            {
                requestContext.HttpContext.Items["themeName"] = previewTheme;
            }

            base.Execute(requestContext);
        }
    }
}